<?php
include "../include/global.php";
include "../include/admin_check.php";
include "../../FCKeditor/fckeditor.php";
$xtpl = new XTemplate ("destinationWrite.htm");
include "setting.php";
//
include "../include/function.php";
$xtpl->assign("left_panel", left_panel());
$xtpl->assign("header_panel", header_panel());
$xtpl->assign("footer_panel", footer_panel());
include "setting.php";

// ++ lang
if($lang=='v'){
	$xtpl->assign('type_vietnamese', 'onkeyup="initTyper(this)"');
}
$xtpl->assign("title", Destination);
$xtpl->assign("lbl_search", Search);
$xtpl->assign("lbl_no", No);
$xtpl->assign("lbl_catdestination", CatDestination);
$xtpl->assign("lbl_name", Name);
$xtpl->assign("lbl_brief", Brief);
$xtpl->assign("lbl_content", Overview);
$xtpl->assign("lbl_image", Image);
$xtpl->assign("lbl_position", Position);
$xtpl->assign("lbl_active", Active);
$xtpl->assign("lbl_metadescription", MetaDescription);
$xtpl->assign("lbl_metakeyword", MetaKeyword);
$xtpl->assign("lbl_save", Save);
$xtpl->assign("lbl_save_add", SaveAdd);
$xtpl->assign("lbl_cancel", Cancel);
// -- lang

$ID=intval($_GET['ID']);
if($ID){
	$sql="select * from ".pre_table."destination where destination_id='$ID'";
	$row=recordset($sql);
	$catdestination_id=$row['catdestination_id'];
	$destination_name=$row['destination_name'];
	$old_destination_image=$row['destination_image'];	
	$destination_brief=$row['destination_brief'];
	$destination_content=$row['destination_content'];	
	$destination_position=$row['destination_position'];	
	$destination_isactive=$row['destination_isactive'];	
	$destination_metadescription=$row['destination_metadescription'];	
	$destination_metakeyword=$row['destination_metakeyword'];		
	
	if($row[destination_isactive]==1) $ChkActive = "checked";			
	
	$xtpl->assign("destination_name", $destination_name);
	$xtpl->assign("old_destination_image", $old_destination_image);
	$xtpl->assign("destination_brief", $destination_brief);
	$xtpl->assign("destination_content", $destination_content);
	$xtpl->assign("destination_position", $destination_position);
	$xtpl->assign("destination_isactive", $destination_isactive);
	$xtpl->assign("destination_metadescription", $destination_metadescription);
	$xtpl->assign("destination_metakeyword", $destination_metakeyword);	
	$xtpl->assign("ChkActive", $ChkActive);
	$xtpl->assign("id", $ID);
	
	$xtpl->assign("type", "EDIT");	
}else{
	// ++ set position
	$stsql = "SELECT destination_id from ".pre_table."destination WHERE lang='".$lang."'";
	$rssql = execSQL($stsql);
	$numrec=mysql_num_rows($rssql);
	$destination_position=$numrec+1;
	$xtpl->assign("destination_position", $destination_position);
	// -- set position
	
	$xtpl->assign("type", "ADD");	
	$xtpl->assign("ChkActive", "checked");
}

$xtpl->assign("cbo_catdestination", cbo_catdestination($catdestination_id));

// ++ image
if($old_destination_image)
{
	$has_image='<img src='.$path.$old_destination_image.' width="50" align="absmiddle" />&nbsp;&nbsp;<a href="javascript:del_image('.$ID.')">'.Delete.'</a>';
}
$xtpl->assign("has_image", $has_image);


$sBasePath="../../FCKeditor/"; 
$oFCKeditor = new FCKeditor('destination_content') ;
$oFCKeditor->BasePath	= $sBasePath ;
$oFCKeditor->Value		= $destination_content ;
$oFCKeditor->Width	= "100%" ;
$oFCKeditor->Height	= "300" ;

//////////////////////////////////////
$xtpl->parse("MAIN");
eval("?".">".$xtpl->text("MAIN"));
?>